package com.bigdata.controller;

import com.bigdata.entity.pojo.Result;
import com.bigdata.entity.vo.AppFlowTrackingVO;
import com.bigdata.entity.vo.AppMapVO;
import com.bigdata.entity.vo.AppTopVO;
import com.bigdata.entity.vo.LandMarkAppTopVO;
import com.bigdata.service.AppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;


@RestController
@RequestMapping("/app")
public class AppController {

    @Autowired
    private AppService appService;

    @GetMapping("/top")
    public Result<List<String>> getAppTop() {//查询app流量前十名
        Long amount=10L;
        List<AppTopVO>list=appService.getAppTop(amount);
        List<String>appNameList=list.stream().map(AppTopVO::getAppName).collect(Collectors.toList());
        System.out.println(appNameList);
        return Result.success(appNameList);
    }
    @GetMapping("/track")
        public Result<AppFlowTrackingVO> AppFlowTracking() {
        AppFlowTrackingVO appFlowTrackingVO=appService.AppFlowTracking();
       System.out.println(appFlowTrackingVO);
        return Result.success(appFlowTrackingVO);
    }
    @GetMapping("/map")
    public Result<List<AppMapVO>>AppMap(){
       List<AppMapVO>list=appService.getAppMap();
       System.out.println(list);
       return Result.success(list);
    }
    @GetMapping("/rank")
    public Result<LandMarkAppTopVO>LandMarkAppTop(){
        LandMarkAppTopVO landMarkAppTopVO=appService.getAppTrafficOfNetType();
        System.out.println(landMarkAppTopVO);
        return Result.success(landMarkAppTopVO);
    }

    @GetMapping("/distribution")
    public Result<Object> getAppTrafficDistribution(){
        return Result.success(this.appService.getAppTrafficDistribution());
    }

    @GetMapping("/traffic-rank")
    public Result<Object> getAppTrafficRankingRank(){
        return Result.success(this.appService.getAppTrafficRankingRank());
    }

    @GetMapping("/traffic-pie")
    public Result<Object> getAppTrafficRankingPie(){
        return Result.success(this.appService.getAppTrafficRankingPie());
    }


}
